package com.bwie.controller;

import com.bwie.common.domain.Coupon;
import com.bwie.common.domain.CouponType;
import com.bwie.common.domain.EventBrand;
import com.bwie.common.domain.GoodsScope;
import com.bwie.common.domain.request.CouponRequest;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @className: CouponController
 * @Description: TODO
 * @version: v1.８.0
 * @author: 刘茂锴
 * @date: 2025/10/13 11:11
 */
@RestController
@RequestMapping("/coupon")
@CrossOrigin
public class CouponController {
    @Autowired
    private CouponService couponService;

    //优惠券列表
    @PostMapping("/couponList")
    public Result<PageResult<Coupon>> couponList(@RequestBody CouponRequest couponRequest){
        PageResult<Coupon> list=couponService.couponList(couponRequest);
        return Result.success(list);
    }
    //优惠券类型下拉框
    @GetMapping("/couponTypeList")
    public Result couponTypeList(){
        List<CouponType> couponTypeList=couponService.couponTypeList();
        return Result.success(couponTypeList);
    }
    //活动品牌下拉框
    @GetMapping("/eventBrandList")
    public Result eventBrandList(){
        List<EventBrand> eventBrandList=couponService.eventBrandList();
        return Result.success(eventBrandList);
    }

    //添加优惠券
    @PostMapping("/couponAdd")
    public Result couponAdd(@RequestBody @Valid Coupon coupon){
        couponService.couponAdd(coupon);
        return Result.success();
    }

}
